-
Notifications
You must be signed in to change notification settings - Fork 337
Check if rustc exists before building a Rust project type #1461
Check if rustc exists before building a Rust project type #1461
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good! thanks for adding this 😄
src/build/mod.rs
Outdated
@@ -13,6 +13,9 @@ pub fn build(target: &Target) -> Result<(), failure::Error> { | |||
message::info("JavaScript project found. Skipping unnecessary build!") | |||
} | |||
TargetType::Rust => { | |||
let _ = which::which("rustc") | |||
.map_err(|e| failure::format_err!("'rustc' not found: {}", e))?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use wrangler::terminal::styles;
let rust_url = styles::url("https://www.rust-lang.org/tools/install");
.map_err(|e| failure::format_err!("'rustc' not found: {}", e))?; | |
.map_err(|e| failure::format_err!("'rustc' not found, installation documentation can be found here: {}, rust_url))?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets point the devs in the right direction for installation here just so it's easy for them to find.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be good to still print the error message. Maybe:
.map_err(|e| failure::format_err!(
"'rustc' not found: {}. Installation documentation can be found here: {}",
e, styles::url("https://www.rust-lang.org/tools/install")))?;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does the error message look like when it's printed out there? can you give an example?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it'd look something like:
'rustc' not found: cannot find binary path. Installation documentation can be found here: https://www.rust-lang.org/tools/install
Where "cannot find binary path" would be any of the messages from which::Error
#[derive(thiserror::Error, Copy, Clone, Eq, PartialEq, Debug)]
pub enum Error {
#[error("bad absolute path")]
BadAbsolutePath,
#[error("bad relative path")]
BadRelativePath,
#[error("cannot find binary path")]
CannotFindBinaryPath,
#[error("cannot get current directory")]
CannotGetCurrentDir,
#[error("cannot canonicalize path")]
CannotCanonicalize,
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 sounds good to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks :)
Fixes #487